package controllers;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import play.mvc.Controller;
import models.Entities;
import models.FilterByPriority;
import models.Idea;
import models.SearchIdeaResults;

public class Filter extends Controller
{
	/**This method checks the priority entered by the user required to filter upon it. 
	 * According to the priority entered by the user , the search results are filtered
	 * upon it.
	 * @author Mohamed Ali Ahmed
	 */
	public static void FilterBy(){

		
		String search=params.get("PriorityText");
		if(search.equals("High"))
		{
			FilterByPriority results = Idea.filterByPriority(search);
			//List<Idea> finalList = results.ideas1;
			List<Idea> ideasTwo=results.ideasOne;
			render(results,ideasTwo,search);
		}
		else
		if(search.equals("Intermediate"))
		{
			FilterByPriority results = Idea.filterByPriority(search);
			List<Idea> ideasTwo=results.ideasOne;
			//System.out.println("mohamed");
			//List<Idea> finalList = results.ideas1;
			render(results,ideasTwo,search);
		}
		else
		if(search.equals("Low"))
		{
			FilterByPriority results = Idea.filterByPriority(search);
			//System.out.println(results.count);
			List<Idea> ideasTwo=results.ideasOne;
			//List<Idea> finalList = results.ideas1;
			render(results,ideasTwo,search);
		}
		
		else 
		render(search);
	}
	/**
	 * Method to show the results of the filter by id of Idea
	 * @param id
	 * @author Mohamed Ali Ahmed
	 */
	public static void showFilter(long id)
	{
		Idea idea= Idea.findById(id);
		render(idea);
	}
	/**Method that helps in navigation
	 * @author Mohamed Ali Ahmed
	 * 
	 */
	public static void FilterIndex()
	{
		render();
	}
	
}
